#ifndef MATERIALEDITOR_H
#define MATERIALEDITOR_H

#include <QWidget>
#include <material_editor/basematerialeditor.h>
#include <material_editor/materialview.h>
#include <ui_materialeditor.h>
#include <grouptreeitemview.h>
#include <colorpicker.h>
#include <QList>
#include <gfx/material.h>


class EffectTreeModel;
class TexturePackTreeModel;
class MaterialEditor : public BaseMaterialEditorWidget
{
  Q_OBJECT
private:
  enum Action
  {
    Action_ShowTexture,
    Action_ShowEffect,
    Actions_COUNT
  };

  QAction               *_actions[Actions_COUNT];

  MaterialView          *_materialView;
  Material              *_material;

  ColorPicker           *_cpAmbient;
  ColorPicker           *_cpDiffuse;
  ColorPicker           *_cpSpecular;
  ColorPicker           *_cpEmission;

  Ui::MaterialEditor    _gui;
  GroupTreeItemView     *_groupView;

	EffectTreeModel				*_effectTreeModel;
  TexturePackTreeModel  *_texturePackTreeModel;

  void Load ();

private slots:
  void MaterialSpecChanged();

  void on_checkBoxTransparency_stateChanged(int state);
  void on_checkBoxWriteDepth_stateChanged(int state);
  void on_checkBoxTestDepth_stateChanged(int state);
  void on_doubleSpinBoxShininess_valueChanged (double d);

  void on_treeViewTexturePack_customContextMenuRequested (const QPoint &pos);
  void on_treeViewTexturePack_activated (const QModelIndex& index);
  void on_treeViewEffect_activated (const QModelIndex& index);

  void actionsShowTexture_triggered ();

public:
  MaterialEditor(Material* material, MaterialView* view, QWidget *parent = 0);

  void SetMaterial(Material* material);
  Material* GetMaterial();

public slots:
  virtual void Save ();

};

#endif // MATERIALEDITOR_H
